<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="clr-namespace:System;assembly=mscorlib" 
    xmlns:local="clr-namespace:SharpMap.Wpf"
                    xmlns:wpf_pres="clr-namespace:SharpMap.Presentation.Wpf;assembly=SharpMap.Presentation.Wpf"
    >
  <Style TargetType="{x:Type local:LayersListView}">
        <Setter Property="Template">
            <Setter.Value>
            <ControlTemplate TargetType="ListBox" >
            <Border BorderThickness="{TemplateBinding Border.BorderThickness}" 
                    Padding="1,1,1,1" 
                    BorderBrush="{TemplateBinding Border.BorderBrush}" 
                    Background="{TemplateBinding Panel.Background}" 
                    Name="Bd" SnapsToDevicePixels="True">
                        <DockPanel x:Name="_layerControl">
                            <ToolBar DockPanel.Dock="Top" Height="25">
                                <!--<Button>
                                    <Image Source="../Resources/NewRandomGeometry.png"/>
                                </Button>-->

                                <Button Command="{x:Static wpf_pres:MapViewCommands.ShowOpenLayerDialog}">
                                    <Image Source="../Resources/AddTableHS.png"/>
                                </Button>

                                <Button Command="{x:Static wpf_pres:LayerCommands.RemoveLayer}">
                                    <Image Source="../Resources/RemoveTable.png"/>
                                </Button>

                                <Button>
                                    <Image Source="../Resources/Highlight.png"/>
                                </Button>
                                <Button Command="{x:Static wpf_pres:LayerCommands.BringForward}">
                                    <Image Source="../Resources/MoveUp.png"/>
                                </Button>
                                
                                <Button Command="{x:Static wpf_pres:LayerCommands.SendBackward}">
                                    <Image Source="../Resources/MoveDown.png"/>
                                </Button>
                                
                                <!--<Button >
                                    <Image Source="../Resources/EditTableHS.png"/>
                                </Button>-->
                            </ToolBar>
                  <ScrollViewer Padding="{TemplateBinding Control.Padding}" Focusable="False">
                    <ItemsPresenter SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
                </ScrollViewer>
               </DockPanel>
            </Border>
            <ControlTemplate.Triggers>
                <Trigger Property="UIElement.IsEnabled">
                    <Setter TargetName="Bd" Property="Panel.Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
                    <Trigger.Value>
                        <s:Boolean>False</s:Boolean>
                    </Trigger.Value>
                </Trigger>
                <Trigger Property="ItemsControl.IsGrouping">
                    <Setter Property="ScrollViewer.CanContentScroll">
                        <Setter.Value>
                            <s:Boolean>False</s:Boolean>
                        </Setter.Value>
                    </Setter>
                    <Trigger.Value>
                        <s:Boolean>True</s:Boolean>
                    </Trigger.Value>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
       </Setter.Value>
    </Setter>
    
    <Setter Property="ItemsPanel">
        <Setter.Value>
            <ItemsPanelTemplate xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
                <VirtualizingStackPanel IsItemsHost="True" />
            </ItemsPanelTemplate>
        </Setter.Value>
    </Setter>


        <Setter Property="ItemTemplate" >
            <Setter.Value>
                <DataTemplate>
                   <StackPanel Orientation="Horizontal" DataContext="{Binding}">
                            <!--<CheckBox IsChecked="{Binding Enabled}"/>-->
                            <TextBlock Text="{Binding LayerName}"/>
                   </StackPanel>
                 </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>    
</ResourceDictionary>
